<template>
  <Loading v-if="!detail.filmId" />
  <div v-else class="detail">
    <div class="name11" @click="goback">猫眼电影 > {{ detail.name }}</div>
    <div class="top">
      <img :src="detail.poster" />
      <div class="top-r">
        <div class="name">{{ detail.name }}</div>
        <div class="director">{{ detail.director }}</div>
        <div class="category">{{ detail.category }}</div>
        <div class="premiereAt">
          {{ detail.premiereAt | frmDate }}{{ detail.nation }}上映 /
          {{ detail.runtime }}
          分钟
        </div>
        <div class="button">
          <van-button
            class="button1"
            type="primary"
            size="normal"
            color="#757b87"
          >
            <van-icon name="like" />
            想看</van-button
          >
          <van-button
            class="button1"
            type="primary"
            size="normal"
            color="#757b87"
          >
            <van-icon name="star" />
            看过</van-button
          >
        </div>
      </div>
    </div>
    <!-- 简介 -->
    <div class="jj">
      <div class="ti">
        <span>简介</span>
        <span @click="clickFn">展开 ></span>
      </div>
      <div class="jjcon" :class="{ hidding }" @click="clickFn">
        {{ detail.synopsis }}
      </div>
    </div>

    <!-- 演职人员 -->
    <div class="actors_list">
      <div>
        <div class="actors"><span>演职人员</span></div>
      </div>
      <MySwiper :preview="4" :height="400">
        <div
          class="swiper-slide"
          v-for="item in detail.actors"
          v-bind:key="item.id"
        >
          <img style="width: 80px" :src="item.avatarAddress" />
          <div class="actors_name">{{ item.name }}</div>
          <div class="actors_name99">饰 {{ item.role }}</div>
        </div>
      </MySwiper>
    </div>

    <div class="bottom">
      <span class="span1">
        <van-icon name="share" />
      </span>
      <span class="span2">
        <button class="button2" color="#fc383b">特惠购票</button>
      </span>
    </div>
  </div>
</template>

<script>
import MySwiper from "../../components/MySwiper";

export default {
  data() {
    return {
      detail: {},
      hidding: true,
    };
  },
  components: {
    MySwiper,
  },
  props: {
    id: String | Number,
  },
  methods: {
    clickFn() {
      this.hidding = !this.hidding;
    },
    goback() {
      this.$router.go(-1)
    },
  },
  // 进入详情页，让主页foot隐藏
  created() {
    this.$eventBus.$emit("hideMenu", false);
  },
  beforeDestroy() {
    this.$eventBus.$emit("hideMenu", true);
  },
  async mounted() {
    let id = +this.id;
    if (id != 0 && !isNaN(id)) {
      let ret = await this.$api.getFilmInfo(this.id);
      // console.log(ret);
      this.detail = ret.data.film || {};
    }
  },
};
</script>
<style lang='scss' scoped>
.detail {
  padding: 20px 14px 0;
  box-sizing: border-box;
  background: #2b3447;
  .name11 {
    color: #ccc;
  }
  .top {
    width: 100%;
    height: 160px;
    margin-top: 20px;

    img {
      width: 110px;
      height: 150px;
      float: left;
      margin-right: 8px;
    }
    .top-r {
      display: flex;
      flex-direction: column;
      justify-content: space-around;
      height: 150px;
      .name {
        color: #fff;
        font-size: 18px;
        font-weight: bold;
      }
      .director {
        color: #ccc;
        font-size: 12px;
      }
      .category {
        color: #ccc;
        font-size: 12px;
      }
      .premiereAt {
        color: #ccc;
        font-size: 12px;
      }
      .button {
        .button1 {
          width: 90px;
          height: 40px;
          margin-right: 20px;
        }
      }
    }
  }
  .jj {
    .ti 
    span {
      color: #fff;
      font-size: 16px;
      margin: 10px 0 0 0;
    }
    span:nth-child(2){
      float: right;
    }
    .jjcon {
      color: #fff;
      font-size: 16px;
      margin: 10px 0 0 0;
      line-height: 25px;
    }
  }
  .actors_list {
    .actors span {
      display: block;
      color: #fff;
      font-size: 16px;
      margin: 20px 0 10px 0;
    }
    .swiper-slide {
      .actors_name {
        height: 14px;
        text-align: center;
        color: #fff;
        font-size: 12px;
        overflow: hidden;
      }
      .actors_name99 {
        height: 14px;
        text-align: center;
        color: #757b87;
        font-size: 12px;
        margin-top: 3px;
      }
    }
  }
  .hidding {
    height: 70px;
    overflow: hidden;
  }
  .bottom {
    position: fixed;
    bottom: 0;
    width: 375px;
    height: 50px;
    margin-left: -14px;
    background: #fff;
    .span1 {
      width: 50px;
      padding: 20px 20px 0 20px;
    }
    .span2 {
      width: 325px;
      .button2 {
        background: #fc383b;
        width: 300px;
        height: 50px;
        color: #fff;
        border: none;
        border-radius: 25px;
      }
    }
  }
}
</style>
